package cn.melonlib.aap.user.model.entity;

import cn.melonlib.aap.user.model.enums.PasswordStrength;
import cn.melonlib.cores.commons.model.anno.MelonEntityId;
import cn.melonlib.cores.commons.model.enums.IdType;
import cn.melonlib.cores.commons.model.enums.IdValueType;
import cn.melonlib.cores.commons.model.support.number_id.MelonLibLongIdEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;


@Data
@EqualsAndHashCode(callSuper = true)
@Entity(name = "AccountPassword")
@Table(name = "user_account_password")
@ModelComment("登陆用户密码")
@MelonEntityId(type = IdType.SNOW_FLAKE,IdValueType = IdValueType.LONG)
public class AccountPassword extends MelonLibLongIdEntity {

    @ManyToOne(cascade = CascadeType.REFRESH,fetch = FetchType.LAZY)
    @JoinColumn(name = "account_id")
    @ModelComment("账户")
    private Account account;

    @Column@Lob@Basic(fetch = FetchType.LAZY)
    @Type(type = "org.hibernate.type.TextType")
    @ModelComment("密码，经过AES加密")
    private String password;

    @ModelComment("密码强度评分 最低0 最高100")
    private Integer score=0;

    @Enumerated(EnumType.STRING)
    @ModelComment("密码强度等级")
    private PasswordStrength strength;

    @ModelComment("密码设置时间")
    private Long initDateTime=System.currentTimeMillis();

}
